<script>
	import {doLogin} from "@/api/api"
	export default {
		globalData:{
		   scene:0,
		   show_ad:true,
		   net_ad:false,
		   recommend_xcx:[],
		   xcx_ad:{
			   video:"adunit-709dca6eac97e462",
			   interstitialId:"adunit-883dc44985f22866",
			   jili:"adunit-99ee5bc4fc5ede0d",
			   banner:"adunit-5da57463da6d4b44",
			   GridJzId:"adunit-d946d93acbcac988",
			   GridLeftId_5:"adunit-47d8c048d7158f69",
			   GridLeftId_4:"adunit-fdaef0cf41b9358a",
			   GridLeftId_3:"adunit-4308a0efae6c394a",
			   GridLeftId:'',
			   GridRightId_5:"adunit-8fbd91de70adfe9e",
			   GridRightId_4:"adunit-68692a1ae085e45b",
			   GridRightId_3:"adunit-350e39b9b8578590",
			   GridRightId:'',
		   },
		   _windowWidth:0,
		   _windowHeight:0
		},
	
		onLaunch: function(a) {
			 let timestampInSeconds = Math.floor(new Date().getTime() / 1000);
			 console.log(timestampInSeconds)
	        if(timestampInSeconds<1728112247){
				this.globalData.xcx_ad.video="adunit-709dca6eac97e462"
				this.globalData.xcx_ad.interstitialId="adunit-883dc44985f22866"
				this.globalData.xcx_ad.jili="adunit-99ee5bc4fc5ede0d"
				this.globalData.xcx_ad.banner="adunit-5da57463da6d4b44"
				this.globalData.xcx_ad.GridJzId=""
				this.globalData.xcx_ad.GridLeftId_5=""
				this.globalData.xcx_ad.GridLeftId_4=""
				this.globalData.xcx_ad.GridLeftId_3=""
				this.globalData.xcx_ad.GridLeftId=''
				this.globalData.xcx_ad.GridRightId_5=""
				this.globalData.xcx_ad.GridRightId_4=""
				this.globalData.xcx_ad.GridRightId_3=""
				this.globalData.xcx_ad.GridRightId=''
	        }
			
			let sysInfo = uni.getSystemInfoSync()
			console.log(sysInfo)
			this.globalData._windowWidth = sysInfo.windowWidth
			this.globalData._windowHeight = sysInfo.screenHeight
			console.log(this.globalData._windowWidth)
			console.log(this.globalData._windowHeight)
			
			
			
			if(this.globalData._windowHeight>900){
				console.log(5)
				this.globalData.xcx_ad.GridLeftId = this.globalData.xcx_ad.GridLeftId_5
				this.globalData.xcx_ad.GridRightId = this.globalData.xcx_ad.GridRightId_5
				
			}else if(this.globalData._windowHeight>800){
				console.log(4)
				this.globalData.xcx_ad.GridLeftId = this.globalData.xcx_ad.GridLeftId_4
				this.globalData.xcx_ad.GridRightId = this.globalData.xcx_ad.GridRightId_4
			}else{
				console.log(3)
				this.globalData.xcx_ad.GridLeftId = this.globalData.xcx_ad.GridLeftId_3
				this.globalData.xcx_ad.GridRightId = this.globalData.xcx_ad.GridRightId_3
			}
			const scene = a.scene
			this.globalData.scene = scene
			//如果没有获取到openid的，进来的时候获取一次，然后刷新
			const query1  = a.query
			for(let i in query1){
				if(i=='fappid'){
					uni.setStorageSync('fappid',query1[i])
				}
			}
			
			if(!uni.getStorageSync('is_login')){
				uni.login({
					success: (e) => {
						const code = e.code
						console.log(code)
						doLogin(code).then(res=>{
							if(res.code==0){
								uni.setStorageSync('token',res.data.token)
								uni.setStorageSync('userinfo',res.data.userinfo)
								uni.setStorageSync('user_id',res.data.userinfo.id)
								uni.setStorageSync('is_login',true)
								const query  = a.query
								var newquery = ''
								for(let i in query){
									newquery +=  i +'=' + query[i] + '&'
								}
								//首次进来刷新当前页面，回去opnid
								uni.reLaunch({
									url:'/'+a.path+'?'+newquery
								})
							}else{
								//网络连接出错
							}
							console.log(res)
						})
					}
				})
			}

		},
		onShow: function() {
			
		},
		onHide: function() {
			
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "@/uni_modules/uview-ui/index.scss";
	@import "common/demo.scss";
	.grid_jz{position: fixed;z-index: 99999;top: 160px;width: 100vw;}
	.grid_left{position: fixed;left: 10px;z-index: 10000;top: 175px}
	
	.grid_right{position: fixed;z-index: 10000;top: 175px}
	
	.ml10{margin-left: 10rpx;}
	.ml15{margin-left: 15rpx;}
	.ml20{margin-left: 20rpx;}
	
	.mr10{margin-right: 10rpx;}
	.mr15{margin-right: 15rpx;}
	.mr20{margin-right: 20rpx;}
	
	.mt10{margin-top: 10rpx;}
	.mt20{margin-top: 20rpx;}
	.mt30{margin-top: 30rpx;}
	.mt580{margin-top: 550rpx;}
	
	
	.mb30{margin-bottom: 30rpx;}
	.mb10{margin-bottom: 10rpx;}
	.mb20{margin-bottom: 20rpx;}
	
	
	.mg10_15{margin: 10rpx 15rpx}
	.mg10_30{margin: 10rpx 30rpx}
	.mg30_20{margin: 30rpx 20rpx}
	.mg10{margin: 10rpx;}
	
	.pd10_15{padding: 10rpx 15rpx}
	.p5{padding: 5rpx;}
	.p10{padding: 10rpx;}
	.pdt10{padding-top: 10rpx;}
	.pdt20{padding-top: 20rpx;}
	.pdt30{padding-top: 30rpx;}
	.pd30{padding: 30rpx;}
	.pd0_10{padding: 0 10rpx;}
	.pd0_20{padding: 0 20rpx;}
	.pd20_0{padding: 20rpx 0;}
	.pdb30{padding-bottom: 30rpx;}
	.pdr20{padding-right: 20rpx;}
	
	.col_999{color: #999999;}
	.col_fff{color: #FFFFFF;}
	.prel{position: relative;}
	
	.w100{width: 100%;}
	.w50{width: 50%;}
	.w120{width: 120rpx;}
	.w300{width: 300rpx;}
	.w550{width: 550rpx;}
	.w150{width: 150rpx;}
	.w710{width: 710rpx;}
	.w370{width: 370rpx;}
	.w450{width: 450rpx;}
	.h120{height: 120rpx;}
	.h95{height: 95rpx;}
	.h110{height: 110rpx;}
	.h170{height: 170rpx;}
	.h150{height: 150rpx;}
	.h100{height: 100rpx;}
	.h200{height: 200rpx;}
	.h350{height: 350rpx;}
	.txt_c{text-align: center;}
	.txt_l{text-align: left;}
	.txt_r{text-align: right;}
	.fz25{font-size: 25rpx;}
	.fz30{font-size: 30rpx;}
	.fz40{font-size: 40rpx;}
	.flex_wrap{flex-wrap: wrap;}
	.flex_wrap_nowrap{flex-wrap: nowrap;}
	.flex{display: flex;}
	.flex_list{flex: 1;}
	.flex_ac{align-items: center;}
	.flex_as{align-items: flex-start;}
	.flex_ae{align-items: flex-end;}
	.flex_jc{justify-content: center;}
	.flex_jl{justify-content: flex-start;}
	.flex_jr{justify-content: flex-end;}
	.flex_jsa{justify-content: space-around;}
	
	.flex_ac{align-items: center;}
	.flex_ae{align-items: flex-end;}
	.flex_jc{justify-content: center;}
	.flex_jl{justify-content: flex-start;}
	.flex_jr{justify-content: flex-end;}
	.flex_js2{justify-content: space-between;}
	.flex_vc{justify-content: center;}
	.flex_vl{justify-content: flex-start;}
	.flex_vr{justify-content: flex-end;}
	.flex_hc{align-items: center;}
	.flex_ht{align-items: flex-start;}
	.flex_hd{align-items: flex-end;}
	
	.hidden{overflow: hidden;}
	.hidden1{overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 1;-webkit-box-orient: vertical}
	.hidden2{overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical}
	.hidden3{overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 3;-webkit-box-orient: vertical}
	.hidden4{overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp: 4;-webkit-box-orient: vertical}
	.w100{width: 100%;}
	
	.borr20{border-radius: 20rpx;}
	
	.shouping{animation: moreGameIcon 2s infinite;}
	@keyframes moreGameIcon {
	    0% {
	        transform: rotate(0);
	    }
	
	    10% {
	        transform: rotate(10deg);
	    }
	
	    20% {
	        transform: rotate(-10deg);
	    }
	
	    30% {
	        transform: rotate(10deg);
	    }
	
	    40% {
	        transform: rotate(-10deg);
	    }
	
	    50% {
	        transform: rotate(0);
	    }
	
	    100% {
	        transform: rotate(0);
	    }
	}
	
	.btn-click {transform: scale(0.9,0.9)!important;transition: all 0.1s;}
	
	
	.backzhezhao{width: 100%;height: 100%;border-radius: 100%;background-color: #000000;
		opacity: .5;position: absolute;top: 0;}
	.back{width: 60rpx;height: 60rpx;position: fixed;top: 38px;left: 24px;z-index: 99999;}
	.back image{width: 100%;height: 100%;z-index: 3;position: relative;}
	
</style>
